package com.controller;

import com.anno.FrontLogin;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

@Controller
@RequestMapping("/sourcePage")
public class SourcePageController {

    @RequestMapping("/forward")
    public ModelAndView forward(String url, HttpServletRequest request, ModelAndView mv) {
        Enumeration<String> names = request.getHeaderNames();
        while(names.hasMoreElements()) {
            String name = names.nextElement();
            String header = request.getHeader(name);
            System.out.println("name = " + name + ", header = " + header);
        }
        System.out.println(url.substring(1, url.length() - 1));
        mv.setViewName("redirect:" + url);
        return mv;
    }
}
